//
//  SpecDetailTableViewCell.m
//  TryShopping
//
//  Created by LiYinDi on 16/6/21.
//  Copyright © 2016年 RuiBen. All rights reserved.
//

#import "SpecDetailTableViewCell.h"

@implementation SpecDetailTableViewCell

- (void)awakeFromNib {
    // Initialization code
    [self setAutoLayout];
    [_moreBtn addTarget:self action:@selector(moreBtnClick:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)setModel:(SpecDetailCellModel *)model
{
 
    _specLabel.text=[NSString stringWithFormat:@"%@/%@",model.colourName,model.sizeName];
    _stockLabel.text=[NSString stringWithFormat:@"本店库存 %d",[model.specInv intValue]];
}
-(void)moreBtnClick:(UIButton *)sender
{
    if ([self.delegate respondsToSelector:@selector(moreButton:parentIndex:)]) {
        
        [self.delegate moreButton:sender.tag parentIndex:self.parentIndex];
    }

}
-(void)setAutoLayout
{
    [_specLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(16);
        make.right.equalTo(_moreBtn.mas_left);
        make.height.equalTo(@18);
        make.bottom.equalTo(self.mas_centerY);
    }];
    [_stockLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(16);
        make.right.equalTo(_moreBtn.mas_left);
        make.height.equalTo(@18);
        make.top.equalTo(self.mas_centerY);
    }];
    [_moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).with.offset(-10);
        make.left.equalTo(_specLabel.mas_right);
        make.top.equalTo(self.mas_top);
        make.centerY.equalTo(self.mas_centerY);
    }];
    [_moreBtnImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_moreBtn.mas_right);
        make.width.equalTo(@30);
        make.height.equalTo(@30);
        make.centerY.equalTo(_moreBtn.mas_centerY);
    }];
    [_moreBtnText mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_moreBtnImage.mas_left);
        make.width.equalTo(@70);
        make.height.equalTo(@30);
        make.centerY.equalTo(_moreBtn.mas_centerY);
    }];

//    [_lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.mas_left).with.offset(10);
//        make.right.equalTo(self.mas_right).with.offset(-10);
//        make.height.equalTo(@1);
//        
//        make.bottom.equalTo(self.mas_bottom);
//    }];

}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
